/**
 * 
 */
var pageii =null;

function selpatient(){
	pageii = layer.open({
		title : "选择用户",
		type : 2,
		area : [ "1000px", "80%" ],
		content : rootPath + '/patient/list.shtml?flag=true',
		btn: ['确定','关闭'],
        yes: function(index,layero){
        	var data = window["layui-layer-iframe" + index].getseldata();
        	var patient = data[0];
        	$("#patient_id").val(patient.id);
        	$("#patient_number").val(patient.patient_number);
        	$("#patient_name").val(patient.patient_name);
        	$("#patient_sex").val(patient.patient_sex);
        	$("#patient_age").val(patient.patient_age);
        	$("#patient_phone").val(patient.patient_phone);
        	$("#patient_address").val(patient.patient_address);
        	changeSex();
        	layer.close(index);
        } 
	});
}

function savepatient(){
	var patient_id = $("#patient_id").val();
	var patient_name = $("#patient_name").val();
	var patient_number = $("#patient_number").val();
	var patient_sex = $("#patient_sex").val();
	var patient_age = $("#patient_age").val();
	var patient_phone = $("#patient_phone").val();
	var patient_address = $("#patient_address").val();
	if(patient_name==null||patient_name==""||patient_name==undefined){
		layer.msg("姓名不能为空！");
		return;
	}
	if(patient_sex==null||patient_sex==""||patient_sex==undefined){
		layer.msg("性别不能为空！");
		return;
	}
	if(patient_age==null||patient_age==""||patient_age==undefined){
		layer.msg("年龄不能为空！");
		return;
	}
	if(patient_id==null||patient_id==""||patient_id==undefined){
		//新增
		jQuery.ajax({
			url : rootPath + '/patient/save.shtml',
			data : $("#patient_info").serialize(),
			type : "post",
			dataType : "json",
			success : function(data) {
				if (data.flag == 'success') {
					$("#patient_id").val(data.id);
					$("#patient_number").val(data.patient_number);
					layer.msg("保存成功！");
				} else {
					layer.msg("保存失败！");
				}
			}
		});
	}else{
		//修改
		jQuery.ajax({
			url : rootPath + '/patient/editEntity.shtml',
			data : $("#patient_info").serialize(),
			type : "post",
			success : function(data) {
				data = eval(data);
				if (data == 'success') {
					layer.msg("修改成功！");
				} else {
					layer.msg("修改失败！");
				}
			}
		});
	}

}

function getPhsicalScore(){
	var patient_number = $("#patient_number").val();
	if(patient_number==null||patient_number==""||patient_number==undefined){
		layer.msg("请先保存患者信息！");
		return;
	}
	
	var pinghe = $("input[id='pinghe']:checked").map(function (){ return $(this).val(); }).get().join(",") + ',' + $("input[id='pinghe_qixu']:checked").map(function (){ return $(this).val(); }).get().join(",")
	+ ',' + $("input[id='pinghe_xieyu']:checked").map(function (){ return $(this).val(); }).get().join(",");
	
	var yangxu = $("input[id='yangxu']:checked").map(function (){ return $(this).val(); }).get().join(",") + ',' + $("input[id='yangxu_qixu']:checked").map(function (){ return $(this).val(); }).get().join(",");
	var yinxu = $("input[id='yinxu']:checked").map(function (){ return $(this).val(); }).get().join(",") + ',' + $("input[id='yinxu_qixu']:checked").map(function (){ return $(this).val(); }).get().join(",");
	var qixu = $("input[id='qixu']:checked").map(function (){ return $(this).val(); }).get().join(",") + ',' + $("input[id='yangxu_qixu']:checked").map(function (){ return $(this).val(); }).get().join(",")
	+ ',' + $("input[id='pinghe_qixu']:checked").map(function (){ return $(this).val(); }).get().join(",") + ',' + $("input[id='yinxu_qixu']:checked").map(function (){ return $(this).val(); }).get().join(",");
	
	var tanshi = $("input[id='tanshi']:checked").map(function (){ return $(this).val(); }).get().join(",");
	var shire = $("input[id='shire']:checked").map(function (){ return $(this).val(); }).get().join(",");
	var xieyu = $("input[id='xieyu']:checked").map(function (){ return $(this).val(); }).get().join(",") + ',' + $("input[id='pinghe_xieyu']:checked").map(function (){ return $(this).val(); }).get().join(",");
	var tebing = $("input[id='tebing']:checked").map(function (){ return $(this).val(); }).get().join(",");
	var qiyu = $("input[id='qiyu']:checked").map(function (){ return $(this).val(); }).get().join(",");
	
	//测试
//	alert("pinghe："+pinghe);
//	alert("yangxu："+yangxu);
//	alert("yinxu：" +yinxu);
//	alert("qixu："  +qixu);
//	alert("tanshi："+tanshi);
//	alert("shire：" +shire);
//	alert("xieyu：" +xieyu);
//	alert("tebing："+tebing);
//	alert("qiyu："  +qiyu);
	$("#loadhtml").load(rootPath + "/physical/create.shtml?id=38&patient_number="+patient_number+"&pinghe="+pinghe+"&yangxu="+yangxu+"&yinxu="+yinxu+"&qixu="+qixu+"&tanshi="+tanshi+"&shire="+shire+"&xieyu="+xieyu+"&tebing="+tebing+"&qiyu="+qiyu);
	
	
}

